//
//  EnterpriseWorkService.m
//  homeland
//
//  Created by Alawn on 13-10-23.
//  Copyright (c) 2013年 xzysun. All rights reserved.
//

#import "EnterpriseWorkService.h"
#import "StreetInfoCell.h"
#import "WorkQuerySelectEntity.h"
#import "EnterpriseWorkEntity.h"
@interface EnterpriseWorkService()
@property (assign, nonatomic) SelectedWorkType currentSelectedType;
@end
@implementation EnterpriseWorkService
-(id)init
{
    self = [super init];
    if (self) {
//        _dataItemName = @"WorkQuerySelectEntity";
          _dataItemName = @"EnterpriseWorkEntity";
        self.currentSelectedType =SelectedSubject;
    }
    return self;
}

-(NSArray *)getSegmentsTitles:(int)index
{
    return [NSArray arrayWithObjects:@"tab_selected_bm", nil];
}


-(void)selectSegmentBarAtIndex:(NSInteger)selected
{
    [self cancelAllRequest];
    switch (selected) {
        case 0:
            self.currentSelectedType = SelectedSubject;
            break;
        case 1:
            self.currentSelectedType = SelectedActivity;
            break;
        default:
            break;
    }
    [self loadDataWithKey:nil];
}

-(void)loadDataWithKey:(NSString *)keyOrNil
{
    _currentPageNo = 1;//刷新或查询的时候将请求页码变为1
    if (self.dataList) {
        self.dataList = nil;
    }
    NSMutableDictionary *params = [NSMutableDictionary dictionary];
//    if (keyOrNil) {
//        [params setValue:keyOrNil forKey:@"category"];
//    } else {
//        [params setValue:@"1" forKey:@"category"];
//    }
//    [params setValue:[NSString stringWithFormat:@"%d",self.currentSelectedType] forKey:@"parentCode"];
    [self doHttpPost:RESERVATION_DEPART_LIST_URL headers:nil path:nil parameters:params];
}

-(void)loadMoreDataWithKey:(NSString *)keyOrNil
{
    NSMutableDictionary *params = [NSMutableDictionary dictionary];
//    if (keyOrNil) {
//        [params setValue:keyOrNil forKey:@"category"];
//    } else {
//        [params setValue:@"1" forKey:@"category"];
//    }
//    [params setValue:[NSString stringWithFormat:@"%d",self.currentSelectedType] forKey:@"parentCode"];
    [self doHttpPost:RESERVATION_DEPART_LIST_URL headers:nil path:nil parameters:params];
}
-(void)configCell:(UITableViewCell *)cell atIndex:(NSIndexPath *)index
{
//    StreetWorkEntity *item = [self.dataList objectAtIndex:index.row];
    EnterpriseWorkEntity *item = [self.dataList objectAtIndex:index.row];
    StreetInfoCell *tempCell = (StreetInfoCell *)cell;
    tempCell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    tempCell.titleLabel.text = item.businessName;
}

-(NSDictionary *)getTargetConfigForCellAtIndex:(NSIndexPath *)indexPath
{
//    WorkQuerySelectEntity *item = [self.dataList objectAtIndex:indexPath.row];
//    item.categoryCode=[NSString stringWithFormat:@"%@",item.category];
//    item.ztsxfl=@"";
//    item.sjfl=@"";
//    item.tddx=@"";
//    NSString *name = item.name;
//    NSString *code = item.parentCode;
//    if ([code compare:@"1"]==NSOrderedSame) {
//        item.ztsxfl=name;
//        item.sjfl=@"";
//        item.tddx=@"";
//    }
//    if ([code compare:@"2"]==NSOrderedSame) {
//        item.ztsxfl=@"";
//        item.sjfl=name;
//        item.tddx=@"";
//    }
//    if ([code compare:@"3"]==NSOrderedSame) {
//        item.ztsxfl=@"";
//        item.sjfl=@"";
//        item.tddx=name;
//    }
    EnterpriseWorkEntity *item = [self.dataList objectAtIndex:indexPath.row];
    NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:@"企业办事指南列表",@"key",item,@"dataItem", nil];
    return dic;
}
@end
